using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Data.Linq.Mapping;
using System.Web.Mvc;

namespace DomainModel.Entities
{
    [Table(Name = "Tasks")]
    public class Task : IDataErrorInfo, IEntityObject, IAuditableEntity, IEntityWithUser
    {
        [Column(IsPrimaryKey = true, IsDbGenerated = true, AutoSync = AutoSync.OnInsert)]
        public int Id { get; set; }
        [Column] public int? ProjectId { get; set; }
        [Column] public Guid UserId { get; set; }
        [Column] public string Name { get; set; }
        [Column] public string Description { get; set; }
        [Column] public DateTime DateCreate { get; set; }
        [Column] public DateTime ? DateComplete { get; set; }
        [Column]
        [DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:dd/mm/yy}")]
        public DateTime ? DateDue { get; set; }
        [Column] public string Status { get; set; }
        [Column] public bool IsComplete { get; set; }
        [Column] public bool Flagged { get; set; }

        public Project Project { get; set; }

        public string this[string columnName]
        {
            get
            {
                if ((columnName == "Name") && string.IsNullOrEmpty(Name))
                    return "Enter task title";
                return null;
            }
        }

        public string Error
        {
            get { return null; }
        }
    }
}